Component({
  properties: {
    mode: {
      type: String,
      value: 'normal', // 普通:normal,精简:lite
    },
    avatar_url: String,
    nickname: String,
    addtime: String,
    star: Array,
    content: String,
    pic_list: Array,
    reply_content: String,
    attr: String,
  },
  data: {
    star_sum: 5,
  },
  ready() {
    let that = this;
    let { star = [], star_sum } = that.data;
    let starTotal = 0;
    if (star && star.length > 0) {
      star.forEach(val => {
        starTotal += Number(val);
      });
      star_sum = starTotal / star.length;
      that.setData({ star_sum });
    }
  },
  methods: {
    commentPicView(e) {
      let _this = this;
      let pic_index = e.currentTarget.dataset.pic_index;
      wx.previewImage({
        current: _this.data.pic_list[pic_index],
        urls: _this.data.pic_list,
      });
    },
  },
});
